<template>
  <div>
    <el-table ref="multipleTable" :data="studentInfo" tooltip-effect="dark" style="width: 100%" v-loading="listLoading"
      :element-loading-text="elementLoadingText" @selection-change="handleSelectionChange">
      <el-table-column show-overflow-tooltip type="selection" width="55"></el-table-column>
      <el-table-column prop="stuNo" label="学生编号">
      </el-table-column>
      <el-table-column prop="realName" label="真实姓名">
      </el-table-column>
      <el-table-column prop="stuTel" label="学生电话">
      </el-table-column>
      <el-table-column prop="stuIdcard" label="学生身份证号">
      </el-table-column>

      <!--      <el-table-column prop="informationImg" label="简历个人照片">
        <template slot-scope="scope">
          <img v-if="scope.row.informationImg" :src="scope.row.informationImg" width="50px" height="50px">
        </template>
      </el-table-column> -->
      <el-table-column prop="stuSex" label="学生性别" :formatter="Sexformatter">
      </el-table-column>
      <el-table-column prop="stuStatus" label="学生状态" :formatter="Statusformatter">
      </el-table-column>

      <el-table-column show-overflow-tooltip label="操作" width="180px">
        <template #default="{ row }">
          <el-button type="text" @click="handleEdit(row)">修改状态</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination :background="background" :current-page="queryForm.current" :layout="layout"
      :page-size="queryForm.size" :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange">
    </el-pagination>


  </div>
</template>

<script>
  import {
    getList
  } from '@/api/student.js'
  export default {
    name: 'studentInfo',
    data() {
      return {
        collageId: 0,
        studentInfo: [],
        pages: 0,
        layout: 'total, sizes, prev, pager, next, jumper',
        background: true,
        multipleSelection: [],
        listLoading: true,
        elementLoadingText: '正在加载...',
        total: 0,
        queryForm: {
          current: 1,
          size: 5,
          paramMap: {
            collageId: ''
          },
        },
      }
    },
    computed: {

      height() {
        return this.$baseTableHeight()
      },
    },
    created() {
      //学院ID
      window.sessionStorage.setItem("schoolId", "1440285428262379522");
      this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId");
    },
    mounted() {
      this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
      console.log("schooleId:", this.queryForm.paramMap.collageId)
      getList(this.queryForm).then(data => {
        if (data.code == 200) {
          this.listLoading = false
          this.studentInfo = data.data.records
          this.total = parseInt(data.data.total)
          this.queryForm.size = parseInt(data.data.size)
          this.queryForm.current = parseInt(data.data.current)

        } else {
          this.$baseMessage(data.msg, 'error')
        }
      })

    },
    methods: {
      Statusformatter(row) {
        console.log(row)
        if (row.stuStatus == 1) {
          return "正常在校"
        } else if (row.stuStatus == 2) {
          return "休学"
        }else if (row.stuStatus == 3) {
          return "毕业"
        }else if (row.stuStatus == 4) {
          return "请假"
        }  else {
          return "离校"
        }
      },
      Sexformatter(row) {
        console.log(row)
        if (row.stuSex == 0) {
          return "男"
        } else if (row.stuSex == 1) {
          return "女"
        } else {
          return "保密"
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      //添加
      handleAdd() {

      },
      //编辑 开启隐藏页面 赋值
      handleEdit(row) {

      },
      handleDelete(){

      },
      //页面改变
      handleSizeChange(val) {
        this.queryForm.size = val
        this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
        console.log("schooleId:", this.queryForm.paramMap.collageId)
        getList(this.queryForm).then(data => {
          if (data.code == 200) {

            this.listLoading = false
            this.studentInfo = data.data.records
            this.total = parseInt(data.data.total)
            this.queryForm.size = parseInt(data.data.size)
            this.queryForm.current = parseInt(data.data.current)

          } else {
            this.$baseMessage(data.msg, 'error')
          }
        })
      },
      handleCurrentChange(val) {
        this.queryForm.current = val
        this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
        console.log("schooleId:", this.queryForm.paramMap.collageId)
        getList(this.queryForm).then(data => {
          if (data.code == 200) {
            this.listLoading = false
            this.studentInfo = data.data.records
            this.total = parseInt(data.data.total)
            this.queryForm.size = parseInt(data.data.size)
            this.queryForm.current = parseInt(data.data.current)

          } else {
            this.$baseMessage(data.msg, 'error')
          }
        })
      },
    }
  }
</script>

<style>
</style>
